<?php
	include "class/cart.php";
	include "config.php";
	//include "config/koneksi.php";
	include "class/produk.php";
	//include "class/kategori.php";
	
	$cart=new Cart();
	$Produk_Dao = new Produk_Dao();
	$produk=$Produk_Dao->get_kategori($_GET['id_kategori']);
	
	if(isset($_REQUEST['command']) && $_REQUEST['command']=='add' &&  $_REQUEST['productid']>0){
		//echo "fsdfsfsfsd";
		//echo $_REQUEST['productid'];
		$pid=$_REQUEST['productid'];
		$cart->addtocart($pid,1);
		header ("location:?menu=shoppingcart");
		exit();
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Products</title>
<script language="javascript">
	function addtocart(pid){
		document.form1.productid.value=pid;
		document.form1.command.value='add';
		document.form1.submit();
	}
</script>
</head>
<body>
<form name="form1" method=post >
	<input type="hidden" name="productid" />
    <input type="hidden" name="command" />
</form>
<div align="left">
<table width=100%><td>
<ul class="nav">
<table width=100% align=left><td align=left height=29><font color=#FFFFFF>Produk Kategori :
<?php 
foreach($produk as $list2){
	//$id_oleh2=$list2->id_oleh2;
}
if(isset($_GET['id_kategori']))
{
	$id_kategori=$_GET['id_kategori'];
}
	$Kategori_Dao=new Kategori_Dao();
    $kategori=$Kategori_Dao->get($id_kategori);
?>
<?php echo ucwords ($kategori->kategori); ?>
</font></td></table>
</ul></table>
</div>
	<table border="0" cellpadding="2px" width="500px">
		<?php
			foreach($produk as $dt){
			//$id_oleh2 = $dt ->id_oleh2;
		?>
    	<tr>
        	<td width=20% height=32><div align=center><font size=2 face=tahoma><?php echo "<a href='?menu=view_produkdetil&&id_oleh2=$dt->id_oleh2'>";?><img src="<?php echo "images/gambar_produk/".$dt->gambar;?>" width="200"</font></div></td>
			<td width=25%><div align=left><font size=2 face=tahoma>
			<a href='?menu=view_produkdetil&&id_oleh2=<?php echo $dt->id_oleh2;?>'><?php echo $dt->nama_oleh2;?></a></font>
			<td width=10% align=center><font size=2 face=tahoma><strong>Rp.</strong></font></td>
			<td width=13%><font size=2 face=tahoma><?php echo $dt->harga; ?></font></td>
			<td width=10% align=right><font size=2 face=tahoma>
			<td><input type="button" value="Tambah Keranjang" onclick="addtocart(<?=$dt->id_oleh2?>)" ></input></td>
		</tr>
        <tr>
    <td colspan='15' align='left' valign='left'><hr color=#cccccc width=110%></td>
	</tr>
        <?php } ?>
    </table>
</div>
</body>
</html>
